(defconst angus-lisp-dir (concat angus-emacs-dir "lisp/"))
(add-to-list 'load-path angus-lisp-dir)


;; color-theme
(add-to-list 'load-path (concat angus-lisp-dir "color-theme/"))
(require 'color-theme)
(color-theme-initialize)
(color-theme-clarity)


;; cedet
(load-file (concat angus-lisp-dir "cedet/common/cedet.el"))
(require 'semantic-ia)
(require 'semantic-gcc)

;; Enable EDE (Project Management) features
(global-ede-mode 1)

;; Enabling Semantic (code-parsing, smart completion) features
(semantic-load-enable-gaudy-code-helpers)

(setq c++-base-dir "/usr/include/c++/4.2/")
(semantic-add-system-include c++-base-dir 'c++-mode)


;; ;; jde
;; (add-to-list 'load-path (concat angus-lisp-dir "cedet/common/"))
;; (add-to-list 'load-path (concat angus-lisp-dir "jde/lisp/"))
;; (add-to-list 'load-path (concat angus-lisp-dir "elib/"))
;; (autoload 'jde-mode "jde" "jde mode." t)


;; ecb
(add-to-list 'load-path (concat angus-lisp-dir "ecb/"))
(require 'ecb-autoloads)
(add-hook 'ecb-activate-before-layout-draw-hook
          (lambda ()
            (ecb-layout-define "angus-right-dir" right nil
                               (ecb-set-directories-buffer)
                               (ecb-split-ver 0.75 t)
                               (other-window 1)
                               (ecb-set-history-buffer)
                               (select-window (next-window)))
            (ecb-layout-define "angus-right-methods" right nil
                               (ecb-set-methods-buffer)
                               (select-window (next-window)))
            (ecb-layout-define "angus-leftright" left-right nil
                               (ecb-set-directories-buffer)
                               (ecb-split-ver 0.75 t)
                               (other-window 1)
                               (ecb-set-history-buffer)
                               (other-window 2)
                               (ecb-set-methods-buffer)
                               (select-window (next-window)))
            (setq ecb-toggle-layout-sequence 
                  (list "angus-right-methods" "angus-right-dir"))
;;;   (list "angus-right-methods" "angus-leftright" "angus-right-dir"))
            (setq ecb-tip-of-the-day nil
                  ecb-auto-compatibility-check nil
                  ecb-version-check nil
                  ecb-layout-name "angus-right-methods"
                  ecb-show-sources-in-directories-buffer 'always
                  ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1
                  ecb-source-path (quote (("/" "/") "/home/angus/programming"))
                  ecb-windows-width 0.25)))



;; desktop
(require 'desktop)
(desktop-save-mode 1)
;; (setq desktop-base-file-name "desktop")
;; (setq desktop-path (list (concat angus-emacs-dir "desktop/")))


;; template
(require 'template)
(template-initialize)
(setq template-expansion-alist '(("HEADER_DATETIME" (template-insert-time "%Y%m%d%H%M%S"))))


;; linum
(require 'linum)
(add-hook 'find-file-hook (lambda () (linum-mode 1)))


;; session
(require 'session)
(setq session-initialize t)
(add-hook 'after-init-hook 'session-initialize)
;; (setq session-save-file angus-session-file)


;; ido
(require 'ido)
(ido-mode t)
;; (setq ido-ignore-buffers
;;        '("\\` " "^\\*" "^ "))


;; ;; xcscope
;; (require 'xcscope)


;; abbrev
(require 'abbrev)
(abbrev-mode t)
(setq abbrev-file-name (concat angus-emacs-dir "abbrev_defs"))
(setq save-abbrevs t)
(quietly-read-abbrev-file)


;; skeleton
(require 'skeleton)
(setq skeleton-pair t)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\'") 'skeleton-pair-insert-maybe)

;; bm
(require 'bm)
;; make bookmarks persistent as default
(setq-default bm-buffer-persistence t)

;; Loading the repository from file when on start up.
(add-hook' after-init-hook 'bm-repository-load)

;; Restoring bookmarks when on file find.
(add-hook 'find-file-hooks 'bm-buffer-restore)

;; Saving bookmark data on killing a buffer
(add-hook 'kill-buffer-hook 'bm-buffer-save)

;; Saving the repository to file when on exit.
;; kill-buffer-hook is not called when emacs is killed, so we
;; must save all bookmarks first.
(add-hook 'kill-emacs-hook '(lambda nil
                              (bm-buffer-save-all)
                              (bm-repository-save)))

;; ;; Update bookmark repository when saving the file.
;; (add-hook 'after-save-hook 'bm-buffer-save)

;; ;; Restore bookmarks when buffer is reverted.
;; (add-hook 'after-revert-hook 'bm-buffer-restore)


;; unicad
(require 'unicad)


;; flyspell
(require 'flyspell)
(add-hook 'text-mode-hook
          (lambda ()
            (flyspell-mode 1)))


;; w3m
(add-to-list 'load-path (concat angus-lisp-dir "emacs-w3m/"))
(require 'w3m-load)


;; yasnippet
(require 'yasnippet)
(yas/initialize)
(yas/load-directory (concat angus-emacs-dir "snippets/"))


;; js2
(autoload 'js2-mode "js2" nil t)

;; python
(require 'python)


;; ;; tabbar
;; (require 'tabbar)
;; (when (require 'tabbar nil t)
;;   (setq tabbar-buffer-groups-function
;; 	(lambda () (list "All Buffers")))
;;   (setq tabbar-buffer-list-function
;; 	(lambda ()
;;   	  (remove-if
;;   	   (lambda(buffer)
;;   	     (find (aref (buffer-name buffer) 0) " *"))
;;   	   (buffer-list))))
;;   (tabbar-mode t))


;; ;; iswitchb
;; (require 'iswitchb)
;; (iswitchb-mode t)
;; (iswitchb-default-keybindings)
;; (setq iswitchb-buffer-ignore '("^[\\*| ]"))


;; ;; muse
;; (setq muse-html-table-attributes " border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\"")
;; (add-hook 'muse-mode-hook 
;;           (lambda ()
;;             (turn-on-orgtbl)
;;             (define-key muse-mode-map [(f7)] 'muse-publish-this-file)))



;; gud
(setq gdb-show-main t)
(setq gud-tooltip-mode t)
(setq gdb-many-windows nil)


;; pymacs
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)


;; ropemacs
;; disable ropemacs shortcuts keys.
(setq ropemacs-enable-shortcuts nil)
(pymacs-load "ropemacs" "rope-")
;; enabling autoimport
(setq ropemacs-enable-autoimport 't)
;; telling ropemacs which modules to cache
;; (setq ropemacs-autoimport-modules '("django"))
;; use a the minibuffer to show doc instead of separate buffer.")
(setq ropemacs-separate-doc-buffer nil)

;; senator
(autoload 'senator-try-expand-semantic "senator")


;; hippie-exp
(setq hippie-expand-try-functions-list
      '(
        ;; senator-try-expand-semantic
        try-expand-dabbrev
        try-expand-dabbrev-visible
        try-expand-dabbrev-all-buffers
        try-expand-dabbrev-from-kill
        try-expand-list
        try-expand-list-all-buffers
        try-complete-file-name-partially
        try-complete-file-name
        try-expand-all-abbrevs
        try-expand-line
        try-expand-line-all-buffers
        try-complete-lisp-symbol-partially
        try-complete-lisp-symbol))

